<template>
	<view class="order_container">
		<z-paging ref="paging" v-model="listData" @query="queryPriceChangeOrderPageByPlatformApp">
			<template #top>
				<view class="mb15">
					<v-tabs v-model="tabCurrent" bgColor="#46ebb0" :scroll="false" activeColor="#333333" fontSize="34rpx"
						lineColor="#33bf8d" lineHeight="6rpx" :bold="true" lineScale="0.3" :tabs="list"
						@change="tabClick()"></v-tabs>
				</view>
			</template>

			<view class="content pt15">
				<view class="d-flex flex-column j-sb content_item w100p mb15" v-for="item in listData" :key="item.orderCode"
					@click="goPage(item)">
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">订单单号</view>
						<view class="value_item">{{item.orderCode || praseStrEmpty}}</view>
					</view>
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">订单属性</view>
						<view class="value_item">{{item.orderType==1?'在线订单':'门店订单'}}</view>
					</view>
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">订单金额</view>
						<view class="value_item">{{item.orderAmount || praseStrEmpty}}</view>
					</view>
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">折扣金额</view>
						<view class="value_item">{{item.orderDiscount || praseStrEmpty}}</view>
					</view>
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">实付金额</view>
						<view class="value_item">{{item.actuallyAmount || praseStrEmpty}}</view>
					</view>
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">确认金额</view>
						<view class="value_item">
							<u-tag plain size="mini" :text="item.confirmAmount" type="success"></u-tag>
						</view>
					</view>
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">订单状态</view>
						<view class="value_item">
							<u-tag plain size="mini" :text="payStatusList[item.auditingStatus].name"
								:type="payStatusList[item.auditingStatus].type"></u-tag>
						</view>
					</view>
					<view class="d-flex a-center j-sb mb15">
						<view class="title_item">创建时间</view>
						<view class="value_item">{{item.createTime || praseStrEmpty}}</view>
					</view>
					<view class="d-flex a-center j-sb">
						<view class="title_item">所属客户</view>
						<view class="value_item">{{item.customerName || praseStrEmpty}}</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import {
		queryPriceChangeOrderPageByPlatformApp
	} from "@/api/index.js"

	export default {
		components: {},
		onLoad(opt) {
			console.log(this.tabCurrent, '****onLoad****');
		},
		onShow() {
			this.tabCurrent = uni.getStorageSync('auditTabCurrent') ? uni.getStorageSync('auditTabCurrent') : 0

			if (this.tabCurrent == 0) {
				this.tabCurrent2 = ""
			} else if (this.tabCurrent == 1) {
				this.tabCurrent2 = "0"
			} else if (this.tabCurrent == 2) {
				this.tabCurrent2 = "1"
				this.$refs.paging.reload()
			} else {
				this.tabCurrent2 = "2"
				this.$refs.paging.reload()
			}

			uni.setStorageSync('auditTabCurrent', 0)

			console.log(this.tabCurrent2, '****onShow****');
		},
		data() {
			return {
				userInfo: uni.getStorageSync('housekeeperInfo'),
				tabCurrent: 0,
				tabCurrent2: 0,
				orderTypeList: [{
						name: "预约单",
					},
					{
						name: "在线支付单",
					},
					{
						name: "在线支付预约时间单",
					},
					{
						name: "线下支付单",
					},
				],
				payStatusList: [{
						name: "待审核",
						type: "primary"
					},
					{
						name: "审核通过",
						type: "success"
					},
					{
						name: "审核拒绝",
						type: "error"
					}
				],
				list: ["全部", "待审核", "审核通过", "审核拒绝"],
				listData: [],
			};
		},
		methods: {
			queryPriceChangeOrderPageByPlatformApp(pageNo, pageSize) {
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				queryPriceChangeOrderPageByPlatformApp({
					pageIndex: pageNo,
					pageSize: pageSize,
					housekeeperCode: this.userInfo.housekeeperCode,
					auditingStatus: this.tabCurrent2,
				}).then(res => {
					this.$refs.paging.complete(res.object.data);
					uni.hideLoading()
				})
			},

			tabClick(item) {
				if (item == 0) {
					this.tabCurrent2 = ""
				} else if (item == 1) {
					this.tabCurrent2 = "0"
				} else if (item == 2) {
					this.tabCurrent2 = "1"
				} else {
					this.tabCurrent2 = "2"
				}

				this.$refs.paging.reload()
			},

			goPage(row) {
				uni.navigateTo({
					url: "/pages/audit/details?orderCode=" + row.orderCode
				});
			}
		},
	};
</script>

<style lang="scss" scopeds>
	page {
		background-color: #f5f5f5;
	}

	.order_container {
		min-height: 100vh;
		background: linear-gradient(179deg, #46ebb0 30%, #ffffff 80%);
		font-family: Source Han Sans CN, Source Han Sans CN-500 !important;

		/deep/ .uni-nav-bar .uni-nav-bar-text {
			font-size: 36rpx !important;
		}

		.content {
			display: flex;
			flex-direction: column;
			align-items: center;
			box-sizing: border-box;
			padding: 0rpx 28rpx;


			.content_item {
				box-sizing: border-box;
				box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);
				border-radius: 16rpx;
				background-color: #fff;
				padding: 40rpx;

				.title_item {
					font-size: 28rpx;
					color: #333333;
				}

				.value_item {
					font-size: 28rpx;
					color: #666666;
				}
			}
		}
	}
</style>